<?php
namespace App\Repositories\Finance;

use App\Models\Finance\FinanceAccountModel;
use App\Repositories\BaseRepository;

class FinanceAccountRepository extends BaseRepository
{
    protected $repository;

    public function __construct()
    {
        $this->repository = new FinanceAccountModel();
    }

    public function getAdminIndex()
    {
        $models = $this->repository->paginate(10);
        $models->limit = 10;
        return $models;
    }

    public function setAdd($data)
    {
        $data['created_at'] = time();
        return $this->repository->insertGetId($data);
    }

    public function setModify($data,$id)
    {
        $data['updated_at'] = time();
        return $this->repository->where('id',$id)
            ->update($data);
    }

    public function getShowOne($id)
    {
        return $this->repository->where('id',$id)->first();
    }

    public function getBindOneByUid($uid)
    {
        return $this->repository
            ->where('uid',$uid)
            ->where('bind',2)
            ->first();
    }
}